# Copyright (C) 2009 Zhang Cong <ftofficer@ftofficer.com>
#  
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without 
# modifications, as long as this notice is preserved.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

AC_INIT([tweakoi],
        [0.0.1],
        [Zhang Cong ftofficer@ftofficer.com],
        [tweakoi])
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([dist-bzip2 dist-zip])

AC_PROG_AWK
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL

AC_CHECK_HEADERS([liboi.h],
	[],
	[AC_MSG_FAILURE(
		[liboi.h not available, make sure you have liboi
		development packages installed. 
		Refer to http://liboi.googlecode.com/])]
)

AC_CHECK_HEADERS([libssh2.h],
	[],
	[AC_MSG_FAILURE(
		[libssh2.h not available, make sure you have liboi
		development packages installed.
		Refer to http://www.libssh2.org for how to.])]
)

AC_MSG_CHECKING(whether to enable debug)
AC_ARG_ENABLE([debug],
	[AS_HELP_STRING([--enable-debug], [Enable debug @<:@default=yes@:>@])])

# Remove CFLAGS -O2 -g flags by default, unless enable_debug is set.
CFLAGS=$(echo $CFLAGS | sed 's/-O2//' | sed 's/-g//')
if test "x$enable_debug" != xno; then
   AC_SUBST([DEBUG_FLAGS], ["-g -DDEBUG -D_DEBUG -UNDEBUG"])
   AC_DEFINE([ENABLE_DEBUG], [1], [Enable debug])
   AC_MSG_RESULT(yes)
else
   AC_SUBST([DEBUG_FLAGS], ["-O2 -UDEBUG -U_DEBUG -DNDEBUG"])
   AC_MSG_RESULT(no)
fi

AC_CONFIG_FILES([
   Makefile
   README
   doc/Makefile
   m4/Makefile
   src/Makefile
])

AC_OUTPUT
